package com.slofzx.nuoda.evaluation.project.compont.imported;

import com.slofzx.nuoda.evaluation.project.enums.ProductTypeEnum;
import com.slofzx.nuoda.evaluation.project.compont.imported.AbstractImportExcelComponent;
import com.slofzx.nuoda.evaluation.project.dao.BatchInfoDAO;
import com.slofzx.nuoda.evaluation.project.entity.BatchInfo;
import com.slofzx.nuoda.evaluation.project.util.BusiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class BatchImportExcelComponent extends AbstractImportExcelComponent {
    @Autowired
    private BatchInfoDAO batchInfoDAO;


    public String getTemplatePath(ProductTypeEnum productType) {
        String templatePath = OIL_TEMPLATE;
        if (ProductTypeEnum.GAS == productType) {
            templatePath = GAS_TEMPLATE;
        }
        return templatePath;
    }

    @Override
    public void updateCostEvaMethod(String targetId, String evaMethod) {
        final BatchInfo batchInfo = batchInfoDAO.selectById(targetId);
        batchInfo.setCostEvaMethod(evaMethod);
        batchInfoDAO.updateById(batchInfo);
    }

    @Override
    public String getMapType(Map<String, String> fieldPositionMap, Map<String, String> rowData) {
        String projectPosition = fieldPositionMap.get("name");
        String typeColIndex = projectPosition.split(BusiUtil.DELIMITER)[1];
        return rowData.get(typeColIndex);
    }

    @Override
    public void checkProject(Map<String, String> fieldPositionMap, List<Map<String, String>> dataList, Integer startRowIndexStr) {

    }
}
